﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VehicleConfigurator.NetUtils;

namespace VehicleConfigurator.Model
{
    public class Option
    {
        public int OID { get; set; }
        public int GroupOID { get; set; }
        public string OptionCode { get; set; }
        private string basename;
        private string explanation;
        public string BaseName
        {
            get
            {
                if (string.IsNullOrEmpty(basename))
                {
                    return string.Empty;
                }
                else
                {
                    return basename;
                }
            }
            set { basename = value; }
        }

        public string BaseNameSafeSQL
        {
            get
            {
                return basename.AddSlashes();
            }
        }

        public string Explanation { get { return explanation; } set { explanation = value; } }

        public string ExplanationSafeSQL { get { return explanation.AddSlashes(); } }

        public List<OptionName> opns { get; set; }
        public Option() { }
        public Option(int oid, int group, string code, string basename, string explanation)
        {
            this.OID = oid;
            this.GroupOID = group;
            this.OptionCode = code;
            this.BaseName = basename;
            this.Explanation = explanation;
        }

        public Option Copy()
        {
            var option = new Option();
            option.OID = this.OID;
            option.GroupOID = this.GroupOID;
            option.OptionCode = this.OptionCode;
            option.BaseName = this.BaseName;
            option.Explanation = this.Explanation;
            if (opns != null)
            {
                option.opns = new List<OptionName>(opns);
            }
            return option;
        }
    }
}
